package cn.wolfcode.domain;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@AllArgsConstructor@NoArgsConstructor
public class AjaxResult {
    private Integer code; //状态码 200表示成功
    private String msg;  // 错误的信息
    private Object data; //正常响应的数据

    //响应成功响应方法
    public static AjaxResult success(){
        return new AjaxResult(200,null,null);
    }
    //返回成功需要返回当前页面的数据
    //data :当前页面数据
    public static AjaxResult success(Object data){
        return new AjaxResult(200,null,data);
    }

    public static AjaxResult success(Object data,String msg){
        return new AjaxResult(200,msg,data);
    }

    public static AjaxResult error(String msg){
        return new AjaxResult(500,msg,null);
    }

    public static AjaxResult error(int code,String msg){
        return new AjaxResult(code,msg,null);
    }
}


